From: Colin Walters Date: Fri, 18 Dec 2009 17:29:25 +0000 (-0500) Subject: [ShellAppSystem] Initialize collation keys for info on-demand X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~10600 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=288eae91e2d7e5547e4d5a3ad305d4a4b8c7b0ef;p=gnome-shell.git [ShellAppSystem] Initialize collation keys for info on-demand In case of duplicate infos structures with the same id, the info structures we get from looking up the id in app_id_to_info aren't necessarily the same as those we used to match, so we can't rely on matching to implicitly initialize info->casefolded_name. Since the name collation key isn't used in matching results, just in sorting, init it on-demand in the sorting which is also more efficient. --- diff --git a/src/shell-app-system.c b/src/shell-app-system.c index ffe3ccc2a..ab609ec1f 100644 --- a/src/shell-app-system.c +++ b/src/shell-app-system.c @@ -622,7 +622,6 @@ shell_app_info_init_search_data (ShellAppInfo *info) name = gmenu_tree_entry_get_name ((GMenuTreeEntry*)info->entry); info->casefolded_name = normalize_and_casefold (name); - info->name_collation_key = g_utf8_collate_key (name, -1); comment = gmenu_tree_entry_get_comment ((GMenuTreeEntry*)info->entry); info->casefolded_description = normalize_and_casefold (comment); @@ -675,6 +674,11 @@ shell_app_info_compare (gconstpointer a, ShellAppInfo *info_a = g_hash_table_lookup (system->priv->app_id_to_info, id_a); ShellAppInfo *info_b = g_hash_table_lookup (system->priv->app_id_to_info, id_b); + if (!info_a->name_collation_key) + info_a->name_collation_key = g_utf8_collate_key (gmenu_tree_entry_get_name ((GMenuTreeEntry*)info_a->entry), -1); + if (!info_b->name_collation_key) + info_b->name_collation_key = g_utf8_collate_key (gmenu_tree_entry_get_name ((GMenuTreeEntry*)info_b->entry), -1); + return strcmp (info_a->name_collation_key, info_b->name_collation_key); }